Check if a given key already existsΒΆ

if k in D

Write a python script to check if a given key already exists in a dictionary.
D = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}

def is_key_present(k):
  if k in D:
      print('Key is present in the dictionary')
  else:
      print('Key is not present in the dictionary')

# test
is_key_present(5)     # Key is present in the dictionary
is_key_present(9)     # Key is not present in the dictionary